package chapter02;

public class Test09_static {
    public static void main(String[] args) {
        Student1 s1 = new Student1("张三",
                "人工智能");
//        Student1.count++;
        Student1.setCount(1);
        Student1 s2 = new Student1("李四",
                "大数据");
        //Student1.count++;
        Student1.setCount(1);
        //输出报道人数
        System.out.println(Student1.getCount());
    }
}
class Student1{
    private String name;
    private String grade;
    private static int count;//全局量
    static {//在类加载的时候执行 执行一遍
        System.out.println("新生报道系统启动...");
    }
    {//每次生成一个对象就执行一次
        System.out.println("新报道一位学生");
    }
    public static void setCount(int n){count = count+n;}
    public static int getCount(){return count;}
    public Student1(String name, String grade) {
        this.name = name;
        this.grade = grade;
    }
}
